import request from '@/utils/request'

export interface ContactDTO {
  contactId?: string
  customerId: string
  contactName: string
  gender?: number
  position?: string
  department?: string
  phone?: string
  tel?: string
  email?: string
  wechat?: string
  qq?: string
  address?: string
  birthday?: string
  roleType?: 'DECISION_MAKER' | 'PURCHASER' | 'USER'
  isPrimary?: number
  status?: number
  remark?: string
}

// 联系人管理API
export function pageContact(params: {
  pageNum: number
  pageSize: number
  customerId?: string
  contactName?: string
  phone?: string
  roleType?: string
  isPrimary?: number
  status?: string
}) {
  return request({ url: '/crm/contact/page', method: 'get', params })
}

export function listContactByCustomer(customerId: string) {
  return request({ url: `/crm/contact/customer/${customerId}`, method: 'get' })
}

export function getContact(id: string) {
  return request({ url: `/crm/contact/${id}`, method: 'get' })
}

export function createContact(data: ContactDTO) {
  return request({ url: '/crm/contact', method: 'post', data })
}

export function updateContact(id: string, data: ContactDTO) {
  return request({ url: `/crm/contact/${String(id)}`, method: 'put', data })
}

export function deleteContact(id: string) {
  return request({ url: `/crm/contact/${String(id)}`, method: 'delete' })
}

export function deleteContactBatch(ids: string[]) {
  return request({ url: '/crm/contact/batch-delete', method: 'post', data: ids })
}

